package view;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.List;

import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTabbedPane;
import javax.swing.JTable;
import javax.swing.JTextArea;
import javax.swing.table.DefaultTableModel;

import dao.StuinfoDao;
import entity.StuInfo;

public class AllShow extends JPanel {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
//	public JTextArea ta;
	private StuInfo stuInfo = new StuInfo();;
	private StuinfoDao stuinfoDao= new StuinfoDao();
	public JTable table;
	
	public AllShow() {
		setLayout(new GridBagLayout());
		GridBagConstraints gbc = new GridBagConstraints();
		
		
		DefaultTableModel dtm=new DefaultTableModel(new Object[][]{},new String[]{"id","name","sex"});//表头	
		JTable table=new JTable(dtm);

//		ta = new JTextArea();
//		ta.setLineWrap(true);
//		ta.setEnabled(false);
//		ta.setDisabledTextColor(Color.BLACK);
		
		JScrollPane sp = new JScrollPane(table);
		gbc.fill = GridBagConstraints.BOTH;
		gbc.weightx = 1;
		gbc.weighty = 1;
		add(sp, gbc);


		
		List<StuInfo> list= stuinfoDao.getAll();
		for (StuInfo s : list) {
			dtm.addRow(s.toArray());
		}
		
		
//		List<StuInfo> stuinfos = stuinfoDao.getAll();
//		for (StuInfo stu : stuinfos) {
//			ta.append(stu.getId() + "\t\t" + stu.getName() + "\t\t" + stu.getSex() + "\n");
		
//		}
	         
		
//		DefaultTableModel dtm=new DefaultTableModel(new Object[][]{},new String[]{"id","name","sex"});
//		JTable table=new JTable(dtm);
//		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//		JScrollPane jsp =new JScrollPane(table);
//	    jsp.setPreferredSize(new Dimension(800, 600));
//		add(jsp);
//		StuinfoDao stuinfoDao=new StuinfoDao();
//		StuInfo stuInfo=new StuInfo();
//		List<StuInfo> list= stuinfoDao.getAll();
//		for (StuInfo s : list) {
//			dtm.addRow(s.toArray());
//		}
		
		
	
	
	
	}

	}



